return "Enables a custom slider. The slider handle is constrained to an 'extent' sprite. Slider sends values as a parameter of an event (SliderSet slider_name, value)." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó Pict for Down - member to represent handle while sliding." & RETURN & "ΓÇó Dynamic - if true value is sent while sliding, else value is sent when the handle is released." & RETURN & "ΓÇó Slider Name - name of slider sent along with value." & RETURN & "ΓÇó Minimum - least value slider can be set to." & RETURN & "ΓÇó Maximum - greatest value slider can be set to." & RETURN & "ΓÇó Extent Sprite - the channel number of the rect that constrains the handle." & RETURN & "ΓÇó Horizontal - Orientation of slider, can be horizontal os vertical."
end
on getAssocMembers
set myPropList to [hiliteMember]
return myPropList
end
on compute_val me
set val to 0.0
set val to float(the currentScreenVal of me) / float(the extentlength of me)
set val to val * the valrange of me
set val to val + the min of me
return val
end
on send_the_val me, val
case the style of me of
#sendAllSprites:
sendAllSprites(#slider_set, the name of me, val)
#sendSprite:
repeat with s in the notifyList of me
sendSprite(s, #slider_set, the name of me, val)
end repeat
#call:
call(#slider_set, the notifyList of me, the name of me, val)
end case
end
on beginSprite me
set the style of me to #sendAllSprites
set the sending of me to 1
set handle to the spriteNum of me
set the tracking of me to 0
set the newLocH of me to the locH of sprite handle
set the newLocV of me to the locV of sprite handle
if the horizontal of me then
set the newLocV of me to the locV of sprite the extentSprite of me
set the minScreen of me to the left of sprite the extentSprite of me
set the maxScreen of me to the right of sprite the extentSprite of me
else
set the newLocH of me to the locH of sprite the extentSprite of me
set the minScreen of me to the top of sprite the extentSprite of me
set the maxScreen of me to the bottom of sprite the extentSprite of me
end if
set the locH of sprite handle to the newLocH of me
set the locV of sprite handle to the newLocV of me
set the valrange of me to the max of me - the min of me
set the extentlength of me to the maxScreen of me - the minScreen of me
if the sending of me = 0 then
set the dynamic of me to 0
end if
end
on endSprite me
end
on prepareFrame me
if tracking then
set handle to the spriteNum of me
set extent to the extentSprite of me
if the horizontal of me then
set the newLocH of me to the mouseH
set the newLocV of me to the locV of sprite extent
if the newLocH of me < the left of sprite extent then
set the newLocH of me to the left of sprite extent
end if
if the newLocH of me > the right of sprite extent then
set the newLocH of me to the right of sprite extent
end if
set the currentScreenVal of me to the newLocH of me - the minScreen of me
else
set the newLocH of me to the locH of sprite extent
set the newLocV of me to the mouseV
if the newLocV of me < the top of sprite extent then
set the newLocV of me to the top of sprite extent
end if
if the newLocV of me > the bottom of sprite extent then
set the newLocV of me to the bottom of sprite extent
end if
set the currentScreenVal of me to the newLocV of me - the minScreen of me
end if
set the locH of sprite handle to the newLocH of me
set the locV of sprite handle to the newLocV of me
if the dynamic of me then
set x to compute_val(me)
send_the_val(me, x)
end if
end if
end
on mouseDown me
set tracking to 1
set temp to the member of sprite the spriteNum of me
set the member of sprite the spriteNum of me to member the hiliteMember of me
set the hiliteMember of me to temp
end
on mouseUp me
set tracking to 0
set temp to the member of sprite the spriteNum of me
set the member of sprite the spriteNum of me to member the hiliteMember of me
set the hiliteMember of me to temp
if the sending of me then
set x to compute_val(me)
send_the_val(me, x)
end if
end
on mouseUpOutSide me
set tracking to 0
set temp to the member of sprite the spriteNum of me
set the member of sprite the spriteNum of me to member the hiliteMember of me